.SUFFIXES: .c .o

COMPILE = $(CC) $(CFLAGS)
INC_PATH = -I/usr/local/include -I.. -I../common
LIB_PATH = $(LIBS) -lm -lfastcommon -lserverframe
TARGET_PATH = $(TARGET_PREFIX)/bin
CONFIG_PATH = $(TARGET_CONF_PATH)

COMMON_OBJS = ../common/fs_proto.o ../common/fs_func.o ../common/fs_global.o \
              ../common/fs_cluster_cfg.o

CLIENT_OBJS = ../client/fs_client.o ../client/client_func.o \
              ../client/client_global.o ../client/client_proto.o \
              ../client/simple_connection_manager.o

SERVER_OBJS = server_func.o service_handler.o cluster_handler.o \
              replica_handler.o common_handler.o data_update_handler.o \
              server_global.o server_group_info.o server_storage.o \
              storage/storage_config.o storage/store_path_index.o \
              storage/trunk_allocator.o storage/storage_allocator.o \
              storage/trunk_prealloc.o storage/trunk_id_info.o \
              storage/object_block_index.o dio/trunk_io_thread.o \
              storage/slice_op.o dio/trunk_fd_cache.o \
              binlog/binlog_func.o binlog/binlog_reader.o \
              binlog/binlog_read_thread.o binlog/binlog_loader.o \
              binlog/trunk_binlog.o binlog/slice_binlog.o   \
              binlog/replica_binlog.o binlog/binlog_check.o \
              binlog/binlog_repair.o replication/replication_processor.o \
              replication/rpc_result_ring.o \
              replication/replication_common.o replication/replication_caller.o \
              replication/replication_callee.o server_binlog.o server_replication.o \
              cluster_relationship.o cluster_topology.o server_recovery.o \
              recovery/binlog_fetch.o recovery/binlog_dedup.o   \
              recovery/binlog_replay.o recovery/data_recovery.o \
              recovery/recovery_thread.o


ALL_OBJS = $(COMMON_OBJS) $(CLIENT_OBJS) $(SERVER_OBJS)

ALL_PRGS = fs_serverd

all: $(ALL_PRGS)

$(ALL_PRGS): $(ALL_OBJS)

.o:
	$(COMPILE) -o $@ $<  $(LIB_PATH) $(INC_PATH)
.c:
	$(COMPILE) -o $@ $<  $(ALL_OBJS) $(LIB_PATH) $(INC_PATH)
.c.o:
	$(COMPILE) -c -o $@ $<  $(INC_PATH)

install:
	mkdir -p $(TARGET_PATH)
	cp -f $(ALL_PRGS) $(TARGET_PATH)
clean:
	rm -f *.o $(ALL_OBJS) $(ALL_PRGS)
